<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
<script src="https://cdn.bootcss.com/vue/2.5.8/vue.js"></script>
<div id="root">
	<p>{{VueMsg}}</p>
	<parent>
		
	</parent>
</div>
<script>
	Vue.component('parent',{
		data : function(){
			return {
				fromSonMsg : '',
			}
		},
		template : `
			<div>
				<div>
					<h1>这是父组件</h1>
					<button @click='getFromSonMsg'>getFromSonMsg</button>
					<span>{{fromSonMsg}}</span>
				</div>
				<hr />
				<child ref='sonMsg'></child>
			</div>
		`,
		methods : {
			getFromSonMsg : function(){
				this.fromSonMsg = this.$refs.sonMsg.sonName;
			}
		},
	});
	Vue.component('child',{
		data : function(){
			return {
				sonName : '你好啊,李金文',
			}
		},
		template : `
			<div>
				<h1>这是子组件 ：{{sonName}}</h1>
			</div>
		`,
	});
	var vm = new Vue({
		el : '#root',
		data : {
			VueMsg : 'Hello VueJs !',
		}
	})
</script>	
</body>
</html>